package com.maigao.persistent;

import com.maigao.entity.jpa.StudentCourse;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.stereotype.Repository;

import java.util.List;

@Repository
public interface StudentCourseRepository extends JpaRepository<StudentCourse, Long> {

    StudentCourse findById(Integer id);

    List<StudentCourse> findByStudentId(Integer studentId);

    @Modifying
    @Query("update StudentCourse set remainCount = ?2 where id = ?1")
    StudentCourse updateMobile(Integer id, Integer remainCount);

    @Modifying
    @Query("update StudentCourse set status = ?2 where id = ?1")
    void updateStudentCourseStatus(Integer id, int newStatus);
}
